package com.yolib.sanyi.tool;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MapOverlay extends ItemizedOverlay<OverlayItem>{

	private ArrayList<OverlayItem> gList = new ArrayList<OverlayItem>();

	Drawable marker;

	public MapOverlay(Drawable defaultMarker) {

		super(defaultMarker);
		marker = defaultMarker;

	}



	@Override
	protected OverlayItem createItem(int arg0) {
		return gList.get(arg0);
	}



	@Override
	public int size() {
		return gList.size();
	}  


	@Override
	public boolean draw(Canvas arg0, MapView arg1, boolean arg2, long arg3) {
		boundCenterBottom(marker);
		return super.draw(arg0, arg1, arg2, arg3);
	}



	public void addOverlayItem(OverlayItem oItem){
		gList.add(oItem);
		populate();
	}
}
